package com.itheima;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
public class CalenderDemo {

    public static void main(String[] args) {

        Calendar calendar = Calendar.getInstance();

        //后退12个月
        calendar.add(Calendar.MONTH, -12);
        for (int i = 0; i < 12; i++) {
            Date date = calendar.getTime();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
            String month = dateFormat.format(date);
            System.out.println(month);
            //前进一个月
            calendar.add(Calendar.MONTH, 1);
        }


    }
}
